import socket
import time

def main():
    sock = socket.socket()
    # host = socket.gethostname() # LAPTOP-U7P83RVN
    host = "127.0.0.1"
    port = 666
    sock.bind((host, port))
    sock.listen(5)

    try:
        while True:
            print("start")
            c, addr = sock.accept()
            print(f"连接地址: {addr}")
            c.send("wdnmd".encode())
            c.close()
    except KeyboardInterrupt:
        print("KeyboardInterrupt")

if __name__ == '__main__':
    main()